package cn.meye11.crm.common;

import java.util.Arrays;

public enum RestResponseCode {
    /**
     *
     */
    BadRequestError(4000, "请求格式错误"),
    MicroServicesError(5000, "微服务错误"),
    MicroServiceUnavailable(5001, "微服务不可用"),
    CircuitBreakerError(5002, "熔断错误"),
    AuthenticationError(5003, "认证错误"),
    PermissionError(5004, "权限错误"),
    ParameterValidError(5005, "参数校验错误"),
    DeprecatedInterface(5006, "接口已过期"),

    ;

    public int id;
    public String name;

    RestResponseCode(int id, String name) {

        this.id = id;
        this.name = name;
    }

    public static RestResponseCode get(int id) {

        return Arrays.stream(RestResponseCode.values()).filter(v -> v.id == id).findFirst().orElse(null);
    }

    @Override
    public String toString() {

        return String.valueOf(id);
    }
}
